package GUI;

import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.event.DocumentListener;

import Controllers.LoginController;

import java.awt.Color;
import java.awt.Font;


/**
 * The Class MarketingDistributionsGUI.
 * Boundary for creating marketing distributions activity
 */
public class MarketingDistributionsGUI extends AbstractPanelGUI {
	
	/** The domain text field. */
	private JTextField domainTf;
	
	/** The type text field. */
	private JTextField typeTf;
	
	/** The comments text field. */
	private JTextField commentsTf;
	
	/** The product combo box. */
	private JComboBox<String> productCb;
	
	/** The button add. */
	private JButton btnAdd;
	
	/** The button back. */
	private JButton btnBack;
	/**
	 * Create the panel.
	 */
	public MarketingDistributionsGUI() {
		LoginController.mainWindow.setTitle("Marketing distributions management");
		setBackground(Color.ORANGE);
		initialize();

	}

	/* (non-Javadoc)
	 * @see GUI.AbstractPanelGUI#initialize()
	 */
	@Override
	public void initialize() {
		setLayout(null);
		setSize(Width,Height);
		
		JLabel lblDomain = new JLabel("Domain:");
		lblDomain.setForeground(new Color(0, 0, 0));
		lblDomain.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblDomain.setBounds(124, 86, 61, 14);
		add(lblDomain);
		
		JLabel lblType = new JLabel("Type:");
		lblType.setForeground(new Color(0, 0, 0));
		lblType.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblType.setBounds(124, 126, 61, 14);
		add(lblType);
		
		domainTf = new JTextField();
		domainTf.setBounds(195, 83, 167, 20);
		add(domainTf);
		domainTf.setDocument(new JTextFieldLimit(45));
		
		typeTf = new JTextField();
		typeTf.setEnabled(false);
		typeTf.setBounds(195, 123, 167, 20);
		add(typeTf);
		typeTf.setDocument(new JTextFieldLimit(45));
		
		JLabel lblComments = new JLabel("Comments:");
		lblComments.setForeground(new Color(0, 0, 0));
		lblComments.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblComments.setBounds(124, 209, 61, 14);
		add(lblComments);
		
		commentsTf = new JTextField();
		commentsTf.setBounds(195, 206, 167, 20);
		add(commentsTf);
		commentsTf.setDocument(new JTextFieldLimit(45));
		
		JLabel lblNewLabel_3 = new JLabel("Product:");
		lblNewLabel_3.setForeground(new Color(0, 0, 0));
		lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblNewLabel_3.setBounds(124, 168, 61, 14);
		add(lblNewLabel_3);
		
		productCb = new JComboBox<String>();
		productCb.setEnabled(false);
		productCb.setBounds(195, 165, 167, 20);
		add(productCb);
		
		btnAdd = new JButton("Add");
		btnAdd.setBounds(380, 304, 89, 23);
		add(btnAdd);
		
		btnBack = new JButton("Back");
		btnBack.setBounds(39, 304, 89, 23);
		add(btnBack);
		
	}

	/**
	 * Gets the domain text field.
	 *
	 * @return the domain text field
	 */
	public JTextField getDomainTf() {
		return domainTf;
	}

	/**
	 * Sets the domain text field.
	 *
	 * @param domainTf the new domain text field
	 */
	public void setDomainTf(JTextField domainTf) {
		this.domainTf = domainTf;
	}

	/**
	 * Gets the type text field.
	 *
	 * @return the type text field
	 */
	public JTextField getTypeTf() {
		return typeTf;
	}

	/**
	 * Sets the type text field.
	 *
	 * @param typeTf the new type text field
	 */
	public void setTypeTf(JTextField typeTf) {
		this.typeTf = typeTf;
	}

	/**
	 * Gets the comments text field.
	 *
	 * @return the comments text field
	 */
	public JTextField getCommentsTf() {
		return commentsTf;
	}

	/**
	 * Sets the comments text field.
	 *
	 * @param commentsTf the new comments text field
	 */
	public void setCommentsTf(JTextField commentsTf) {
		this.commentsTf = commentsTf;
	}

	/**
	 * Gets the product combo box.
	 *
	 * @return the product combo box
	 */
	public JComboBox<String> getProductCb() {
		return productCb;
	}

	/**
	 * Sets the product combo box.
	 *
	 * @param productCb the new product combo box
	 */
	public void setProductCb(JComboBox<String> productCb) {
		this.productCb = productCb;
	}
	
	/**
	 * Adds action listener to add button.
	 *
	 * @param listener the listener
	 */
	public void addButtonAddActionListener(ActionListener listener)
	{
		btnAdd.addActionListener(listener);
	}
	
	/**
	 * Adds action listener to back button.
	 *
	 * @param listener the listener
	 */
	public void addBackButtonActionListener(ActionListener listener)
	{
		btnBack.addActionListener(listener);
	}
	
	/**
	 * Adds document listener to domain text field.
	 *
	 * @param listener the listener
	 */
	public void addDomainDocumentListener(DocumentListener listener)
	{
		domainTf.getDocument().addDocumentListener(listener);
	}
	
	/**
	 * Adds document listener to type text field.
	 *
	 * @param listener the listener
	 */
	public void addTypeDocumentListener(DocumentListener listener)
	{
		typeTf.getDocument().addDocumentListener(listener);
	}
}
